﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class NewBehaviourScript : MonoBehaviour{
	public GameObject[] games;
	public GameObject gameobj;
	// Use this for initialization
	void Start () {
        
		InvokeRepeating("UpQ", 2, 2);
	}
	void UpQ()
    {
		int num=Random.Range(0, games.Length);
		UpQiu(games[num].transform.GetChild(1).gameObject);
	}
	public void UpQiu(GameObject game)
    {
		game.transform.position=Vector3.MoveTowards(game.transform.position, new Vector3(game.transform.position.x, 0.5f, game.transform.position.z),3f );
		Invoke("DownQ", 2);
		gameobj = game;
	}
	public void DownQ()
    {
		DownQiu();

	}
	public void DownQiu()
    {
		gameobj.transform.position = Vector3.MoveTowards(gameobj.transform.position, new Vector3(gameobj.transform.position.x,  -0.5f, gameobj.transform.position.z), 100f);
		Debug.Log("下降球" + gameobj.transform.position);
	}
	private RaycastHit pos;
	// Update is called once per frame
	void Update()
	{
		if(Input.GetMouseButtonDown(0))
        {
			//Ray ray=Camera.main.ScreenPointToRay(Input.mousePosition);
			//Physics.Raycast(ray, out RaycastHit hit);
			//if(hit.transform.gameObject!=null)
   //         {
			//	Debug.Log(hit.transform.name);
   //         }
        }
	}

}
